package com.briup.controller;

import com.briup.entity.Student;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.List;

@RestController
@RequestMapping("/request")
public class RequestController {

    @RequestMapping("/simpleParam")
    public String  simpleParam(String name,int age,@RequestParam(name = "groupName",defaultValue = "友情下一组") String group){
        Student student = new Student(name, age, group);
        System.out.println(student);
        return "你好啊，来自"+group+"的"+name+",听说你今年"+age+"岁";
    }

    @RequestMapping("/entityParam")
    public  String entityParam(Student student){
        System.out.println(student);
        return "你好啊，来自"+student.getGroup()+"的"+student.getName()+",听说你今年"+student.getAge()+"岁";
    }

    @RequestMapping("/listParam")
    public String listParam(@RequestParam List<String> names){
        System.out.println(names.getClass());
        return names.toString();
    }

    @RequestMapping("/dateParam")
    public   String dateParam(@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime dateTime, @DateTimeFormat (pattern = "yyyy-MM-dd") LocalDate date, @DateTimeFormat(pattern = "HH:mm:ss") LocalTime time){

        return  "北京时间："+dateTime;
    }


}
